package com.dk.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class DateTransform {
    public static LocalDateTime strToDate(String str) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.parse(str, df);
    }

    public static void main(String[] args) {
        String dateTime = "2018-01-12 17:07:05";
        DateTimeFormatter inFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(dateTime, inFormat);
        Instant instant = parse.atZone(ZoneId.systemDefault()).toInstant();
        System.out.println(instant.toEpochMilli());
    }
}